package com.lin.mr.maizilaundry.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;

import com.lin.mr.maizilaundry.R;

/**
 * Created by lenovog on 2016/7/7.
 */
public class FragmentMoreView extends FrameLayout {
    private ImageView image_list_item;
    private TextView tv_list_item;
    private ImageView arrow_list_item;
//    private Paint paint;

    public FragmentMoreView(Context context, AttributeSet attrs) {
        super(context, attrs);
//        paint = new Paint();
        View view = View.inflate(context,R.layout.fragment_more_view,this);
        image_list_item = (ImageView) view.findViewById(R.id.image_list_item);
        tv_list_item = (TextView) view.findViewById(R.id.tv_list_item);
        arrow_list_item = (ImageView) view.findViewById(R.id.arrow_list_item);

        //这里取得declare-styleable集合
        TypedArray typedArray = context.obtainStyledAttributes(attrs,R.styleable.MyViewForItem);
        //从declare-styleable集合中取出相对应的属性值，第二个参数是默认值
        Drawable imageItem = typedArray.getDrawable(R.styleable.MyViewForItem_imageItem);
        String textItem = typedArray.getString(R.styleable.MyViewForItem_textItem);
        Drawable arrowItem = typedArray.getDrawable(R.styleable.MyViewForItem_arrowItem);

        image_list_item.setImageDrawable(imageItem);
        tv_list_item.setText(textItem);
        arrow_list_item.setImageDrawable(arrowItem);

        //关闭资源，回收TypedArray
        typedArray.recycle();
    }
}
